The present invention relates generally to the field of distributed transaction processing, and more particularly to recovery of a two-phase commit transaction after failure.
Distributed data processing systems involving multiple resource managers in a single transaction use a two-phase commit protocol found in the XA Specification by The Open Group® to ensure that all resources either commit or rollback any particular transaction consistently. Examples of resources accessed by resource managers using the XA Specification include databases, application servers, message queues, and transactional caches. The act of transferring money from one bank account to a second bank account is an example of a two-phase commit transaction. The data processing system ensures that both actions of debiting money from the first account and of crediting money to the second account, happen either together or not at all. If one side of the transaction is unable to complete for any reason, then the XA protocol provides for rolling back the other transaction which may be ready to commit.
Application programs transmit transactional requests to a middleware transaction manager. The transaction manager coordinates transactions between resource managers using the two-phase commit protocol of the XA Specification. The transaction manager controls the transaction globally, indicating to each resource manager what action is being requested, and when to perform the requested action. The transaction manager allows the completion of a transaction between separate resource managers which may physically reside on different software platforms, as well as separate computers. In the first phase of a two-phase commit, the transaction manager tells each resource to “prepare” to commit by performing all operations for a transaction and being ready to either make the changes permanent (commit) or to undo all the changes (rollback). Each resource manager responds back to the transaction manager indicating whether the operations succeeded or failed. In the second phase, if all operations succeeded, the transaction manager tells all resources to commit the changes. If at least one operation fails, then the transaction manager tells all resources to rollback the changes and indicates a transaction failure to the requesting application program.